apiready = function() {

	var mobileInput = $("#mobile");

	//获取验证码按钮
	var btnGetValiData = $("#btn_getValiData");
	btnGetValiData.on("click", function() {
		$api.sendMobileMsg(mobileInput.val(), function() {
			$api.btnWait(btnGetValiData);
		});
	});

	//注册按钮
	$("#reg_sub").on('click', function() {
		$api.verifyPhone(mobileInput.val(), function(phone) {
			var password = $("#password").val();
			var password2 = $("#password2").val();
			var nickname = $("#nickname").val();
			var agreement = $("#agreement").val();
			if (password !== password2) {
				$api.toastMsg("两次输入的密码不相等");
				return;
			}

			if (!agreement) {
				$api.toastMsg("请阅读并同意该协议");
				return;
			}

			var val = {
				account: phone,
				password: password,
				mobile: phone,
				name: nickname
			};
			$api.do_post("/api/commuser/reg", {
				body: JSON.stringify(val)
			}, function(result) {
				alert(result.msg);
				api.closeToWin({
					name: 'login'
				});
			});
		});
	});
};